package routers

import (
	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
	"zhyc/handlers"
)

func Init() *gin.Engine {

	r := gin.Default()
	r.Use(cors.Default())
	r.Static("static", "./static")

	r.POST("/login", handlers.Login)
	r.POST("/roleNodeAdd", handlers.RoleNodeAdd)
	r.GET("/userRole", handlers.UserRole)
	r.GET("/roleNode", handlers.RoleNode)
	r.POST("/carAdd", handlers.CarAdd)
	r.POST("/orderAdd", handlers.OrderAdd)
	r.GET("/orderList", handlers.OrderList)
	r.GET("/orderDetail", handlers.OrderDetail)

	return r

	//// 1.创建路由
	//r := gin.Default()
	//// 2.绑定路由规则，执行的函数
	//// gin.Context，封装了request和response
	//r.GET("/", func(c *gin.Context) {
	//	c.String(http.StatusOK, "hello World!")
	//})
	//// 3.监听端口，默认在8080
	//// Run("里面不指定端口号默认为8080")
	//r.Run(":8000")
}
